export const useFormRules = (fields = []) => {
    let rules = {};
    fields.forEach((field) => {
        let validate = [];
        if (field?.required) {
            if (field?.rules && field.rules.length) {
                validate.push(...field?.rules);
            } else {
                validate.push({
                    required: true,
                    message: field.key + "不能为空",
                    trigger: "change",
                });
            }
        }
        if (field?.validateRules) {
            validate.push(...field.validateRules);
        }
        rules[field.key] = validate;
    });
    return rules;
};
